/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sosrest;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author pablomosquera
 */
@Entity
@Table(name = "Citas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Citas.findAll", query = "SELECT c FROM Citas c"),
    @NamedQuery(name = "Citas.findByIdCitas", query = "SELECT c FROM Citas c WHERE c.idCitas = :idCitas"),
    @NamedQuery(name = "Citas.findByDescripcion", query = "SELECT c FROM Citas c WHERE c.descripcion = :descripcion"),
    @NamedQuery(name = "Citas.findByFecha", query = "SELECT c FROM Citas c WHERE c.fecha = :fecha"),
    @NamedQuery(name = "Citas.findByRecurrente", query = "SELECT c FROM Citas c WHERE c.recurrente = :recurrente"),
    @NamedQuery(name = "Citas.findByIdCalendario", query = "SELECT c FROM Citas c WHERE c.idCalendariofk = :idCalendariofk"),
    /*@NamedQuery(name = "Citas.findByUsuario", query = "SELECT c FROM Citas c,  IN (c.idCalendariofk) t WHERE t.idCalendario = c.idCalendariofk AND t.idUsuariofk = :idUsuariofk"),*/
    @NamedQuery(name = "Citas.findByUsuario2", query = "SELECT DISTINCT c FROM Citas c INNER JOIN c.idCalendariofk b WHERE c.idCalendariofk = b.idCalendario AND b.idUsuariofk = :idUsuariofk")})
public class Citas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_citas")
    private Integer idCitas;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "descripcion")
    private String descripcion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Basic(optional = false)
    @NotNull
    @Column(name = "recurrente")
    private boolean recurrente;
    @JoinColumn(name = "id_calendariofk", referencedColumnName = "id_calendario")
    @ManyToOne(optional = false)
    private Calendarios idCalendariofk;

    public Citas() {
    }

    public Citas(Integer idCitas) {
        this.idCitas = idCitas;
    }

    public Citas(Integer idCitas, String descripcion, Date fecha, boolean recurrente) {
        this.idCitas = idCitas;
        this.descripcion = descripcion;
        this.fecha = fecha;
        this.recurrente = recurrente;
    }

    public Integer getIdCitas() {
        return idCitas;
    }

    public void setIdCitas(Integer idCitas) {
        this.idCitas = idCitas;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public boolean getRecurrente() {
        return recurrente;
    }

    public void setRecurrente(boolean recurrente) {
        this.recurrente = recurrente;
    }

    public Calendarios getIdCalendariofk() {
        return idCalendariofk;
    }

    public void setIdCalendariofk(Calendarios idCalendariofk) {
        this.idCalendariofk = idCalendariofk;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCitas != null ? idCitas.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Citas)) {
            return false;
        }
        Citas other = (Citas) object;
        if ((this.idCitas == null && other.idCitas != null) || (this.idCitas != null && !this.idCitas.equals(other.idCitas))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sosrest.Citas[ idCitas=" + idCitas + " ]";
    }
    
}
